var app = angular.module(setting.appName);
app.register.controller("UserNicknameCtrl", ["$rootScope", "$scope", "$location", "$timeout", "$window", "ToastMessage", "SecurityService", "UserService", function($rootScope, $scope, $location, $timeout, $window, ToastMessage, SecurityService, UserService) {
    $scope.totalAsserts = 0,
    $scope.status = SecurityService.cache("status"),
    $scope.status && ($scope.nickname = $scope.status.credential.nickname),
    $scope.saveNickname = function(nickname, event) {
        app.util.setDisabled(event.target),
        app.util.loading(event.target, !0),
        UserService.updateNickname(nickname).success(function(data) {
            data && data.message && ToastMessage.show(data.message, data.success),
            data && data.success && $timeout(function() {
                $window.history.back()
            }, 100),
            app.util.setEnabled(event.target),
            app.util.loading(event.target, !1)
        })
    }
    ;
    var funs = {
        loadStatus: function() {
            SecurityService.status(function(data) {
                data && data.success && ($scope.status = data.result,
                $scope.nickname = $scope.status.credential.nickname)
            })
        }
    };
    funs.loadStatus()
}
]);
